<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01 起步</title>
</head>
<body>
  <canvas
    id="c"
    width="300"
    height="200"
    style="border: 1px solid #ccc;"
  ></canvas>

  <script>
    // 1、获取canvas对象
    const context = document.getElementById('c')

    // 2、获取canvas上下文环境对象
    const ctx = context.getContext('2d')

    // 3、绘制图形
    ctx.moveTo(100, 100) // 起点
    ctx.lineTo(200, 100) // 终点
    ctx.stroke() // 将起点和终点连接起来
  </script>
</body>
</html>